{% extends 'base_auth.html' %}

{% block title %}设置新密码 - EasyTesting{% endblock %}

{% block content %}
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-6 col-lg-5">
            <div class="card shadow-sm border-0 mt-5">
                <div class="card-body p-5">
                    <div class="text-center mb-4">
                        <h1 class="h3 mb-3 fw-normal">设置新密码</h1>
                        <p class="text-muted">请输入并确认您的新密码。</p>
                    </div>
                    
                    {% if validlink %}
                        {% if form.errors %}
                        <div class="alert alert-danger">
                            <i class="bi bi-exclamation-triangle-fill me-2"></i>
                            请修正以下错误:
                            <ul class="mb-0 mt-2">
                                {% for field in form %}
                                    {% for error in field.errors %}
                                    <li>{{ field.label }}: {{ error }}</li>
                                    {% endfor %}
                                {% endfor %}
                            </ul>
                        </div>
                        {% endif %}
                        
                        <form method="post">
                            {% csrf_token %}
                            <div class="mb-3">
                                <label for="id_new_password1" class="form-label">新密码</label>
                                <div class="input-group">
                                    <span class="input-group-text"><i class="bi bi-lock"></i></span>
                                    <input type="password" name="new_password1" id="id_new_password1" class="form-control" placeholder="输入新密码" required autofocus>
                                </div>
                                <div class="form-text">
                                    <ul>
                                        <li>密码不能与个人信息太相似。</li>
                                        <li>密码必须至少包含 8 个字符。</li>
                                        <li>密码不能是常用密码。</li>
                                        <li>密码不能全为数字。</li>
                                    </ul>
                                </div>
                            </div>
                            
                            <div class="mb-4">
                                <label for="id_new_password2" class="form-label">确认新密码</label>
                                <div class="input-group">
                                    <span class="input-group-text"><i class="bi bi-lock-fill"></i></span>
                                    <input type="password" name="new_password2" id="id_new_password2" class="form-control" placeholder="再次输入新密码" required>
                                </div>
                                <div class="form-text">请输入与上面相同的密码，以进行验证。</div>
                            </div>
                            
                            <button class="w-100 btn btn-primary" type="submit">
                                <i class="bi bi-check-lg me-2"></i>更改密码
                            </button>
                        </form>
                    {% else %}
                        <div class="alert alert-danger">
                            <i class="bi bi-exclamation-triangle-fill me-2"></i>
                            密码重置链接无效，可能是因为它已经被使用或已过期。请重新申请密码重置。
                        </div>
                        
                        <div class="text-center mt-4">
                            <a href="{% url 'password_reset' %}" class="btn btn-primary">
                                <i class="bi bi-arrow-repeat me-2"></i>重新申请密码重置
                            </a>
                        </div>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
